<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qevent.cpp -->
  <title>QHoverEvent Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QHoverEvent</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QHoverEvent Class</h1>
<!-- $$$QHoverEvent-brief -->
<p>The QHoverEvent class contains parameters that describe a mouse event. <a href="#details">More...</a></p>
<!-- @@@QHoverEvent -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QHoverEvent&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qinputevent.html">QInputEvent</a></td></tr></table></div><ul>
<li><a href="qhoverevent-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#QHoverEvent">QHoverEvent</a></b>(QEvent::Type <i>type</i>, const QPointF &amp;<i>pos</i>, const QPointF &amp;<i>oldPos</i>, Qt::KeyboardModifiers <i>modifiers</i> = Qt::NoModifier)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#oldPos">oldPos</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QPointF &amp;</td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#oldPosF">oldPosF</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#pos">pos</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QPointF &amp;</td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#posF">posF</a></b>() const</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QHoverEvent-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>Mouse events occur when a mouse cursor is moved into, out of, or within a widget, and if the widget has the <a href="../qtcore/qt.html#WidgetAttribute-enum">Qt::WA_Hover</a> attribute.</p>
<p>The function <a href="qhoverevent.html#pos">pos</a>() gives the current cursor position, while <a href="qhoverevent.html#oldPos">oldPos</a>() gives the old mouse position.</p>
<p>There are a few similarities between the events <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverEnter</a> and <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverLeave</a>, and the events <a href="../qtcore/qevent.html#Type-enum">QEvent::Enter</a> and <a href="../qtcore/qevent.html#Type-enum">QEvent::Leave</a>. However, they are slightly different because we do an update() in the event handler of <a href="../qtcore/qevent.html#Type-enum">HoverEnter</a> and <a href="../qtcore/qevent.html#Type-enum">HoverLeave</a>.</p>
<p><a href="../qtcore/qevent.html#Type-enum">QEvent::HoverMove</a> is also slightly different from <a href="../qtcore/qevent.html#Type-enum">QEvent::MouseMove</a>. Let us consider a top-level window A containing a child B which in turn contains a child C (all with mouse tracking enabled):</p>
<p class="centerAlign"><img src="images/hoverevents.png" alt="" /></p><p>Now, if you move the cursor from the top to the bottom in the middle of A, you will get the following <a href="../qtcore/qevent.html#Type-enum">QEvent::MouseMove</a> events:</p>
<ol class="1" type="1"><li>A::MouseMove</li>
<li>B::MouseMove</li>
<li>C::MouseMove</li>
</ol>
<p>You will get the same events for <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverMove</a>, except that the event always propagates to the top-level regardless whether the event is accepted or not. It will only stop propagating with the <a href="../qtcore/qt.html#WidgetAttribute-enum">Qt::WA_NoMousePropagation</a> attribute.</p>
<p>In this case the events will occur in the following way:</p>
<ol class="1" type="1"><li>A::HoverMove</li>
<li>A::HoverMove, B::HoverMove</li>
<li>A::HoverMove, B::HoverMove, C::HoverMove</li>
</ol>
</div>
<!-- @@@QHoverEvent -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QHoverEvent[overload1]$$$QHoverEventQEvent::TypeconstQPointF&constQPointF&Qt::KeyboardModifiers -->
<h3 class="fn" id="QHoverEvent"><a name="QHoverEvent"></a>QHoverEvent::<span class="name">QHoverEvent</span>(<span class="type"><a href="../qtcore/qevent.html#Type-enum">QEvent::Type</a></span> <i>type</i>, const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &amp;<i>pos</i>, const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &amp;<i>oldPos</i>, <span class="type"><a href="../qtcore/qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a></span> <i>modifiers</i> = Qt::NoModifier)</h3>
<p>Constructs a hover event object.</p>
<p>The <i>type</i> parameter must be <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverEnter</a>, <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverLeave</a>, or <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverMove</a>.</p>
<p>The <i>pos</i> is the current mouse cursor's position relative to the receiving widget, while <i>oldPos</i> is its previous such position. <i>modifiers</i> hold the state of all keyboard modifiers at the time of the event.</p>
<!-- @@@QHoverEvent -->
<!-- $$$oldPos[overload1]$$$oldPos -->
<h3 class="fn" id="oldPos"><a name="oldPos"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QHoverEvent::<span class="name">oldPos</span>() const</h3>
<p>Returns the previous position of the mouse cursor, relative to the widget that received the event. If there is no previous position, oldPos() will return the same position as <a href="qhoverevent.html#pos">pos</a>().</p>
<p>On <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverEnter</a> events, this position will always be <a href="../qtcore/qpoint.html">QPoint</a>(-1, -1).</p>
<p><b>See also </b><a href="qhoverevent.html#pos">pos</a>().</p>
<!-- @@@oldPos -->
<!-- $$$oldPosF[overload1]$$$oldPosF -->
<h3 class="fn" id="oldPosF"><a name="oldPosF"></a>const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &amp;QHoverEvent::<span class="name">oldPosF</span>() const</h3>
<p>Returns the previous position of the mouse cursor, relative to the widget that received the event. If there is no previous position, oldPosF() will return the same position as <a href="qhoverevent.html#posF">posF</a>().</p>
<p>On <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverEnter</a> events, this position will always be <a href="../qtcore/qpointf.html">QPointF</a>(-1, -1).</p>
<p><b>See also </b><a href="qhoverevent.html#posF">posF</a>().</p>
<!-- @@@oldPosF -->
<!-- $$$pos[overload1]$$$pos -->
<h3 class="fn" id="pos"><a name="pos"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QHoverEvent::<span class="name">pos</span>() const</h3>
<p>Returns the position of the mouse cursor, relative to the widget that received the event.</p>
<p>On <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverLeave</a> events, this position will always be <a href="../qtcore/qpoint.html">QPoint</a>(-1, -1).</p>
<p><b>See also </b><a href="qhoverevent.html#oldPos">oldPos</a>().</p>
<!-- @@@pos -->
<!-- $$$posF[overload1]$$$posF -->
<h3 class="fn" id="posF"><a name="posF"></a>const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &amp;QHoverEvent::<span class="name">posF</span>() const</h3>
<p>Returns the position of the mouse cursor, relative to the widget that received the event.</p>
<p>On <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverLeave</a> events, this position will always be <a href="../qtcore/qpointf.html">QPointF</a>(-1, -1).</p>
<p><b>See also </b><a href="qhoverevent.html#oldPosF">oldPosF</a>().</p>
<!-- @@@posF -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
